//
//  TTCertificateViewCell.m
//  TaoTuo
//
//  Created by apple on 2020/11/19.
//  Copyright © 2020 刘广. All rights reserved.
//

#import "TTCertificateViewCell.h"

@interface TTCertificateViewCell ()

@property (nonatomic, strong) UILabel *titleLabel;
@property (nonatomic, strong) UILabel *infoLabel;

@end


@implementation TTCertificateViewCell

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = UIColorHex(#F5F5F5);
        
        self.layer.cornerRadius = 5;
        self.layer.borderWidth = 1;
        
        _titleLabel = [UILabel labelTextCenterWithTitle:@"" color:UIColorHex(333333) fontSize:13];
        [self.contentView addSubview:_titleLabel];
        [_titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.mas_equalTo(12);
            make.left.mas_equalTo(8);
            make.right.equalTo(self.contentView.mas_right).mas_offset(-8);
        }];
        
        _infoLabel = [UILabel labelTextCenterWithTitle:@"" color:UIColorHex(333333) fontSize:11];
        _infoLabel.numberOfLines = 2;
        [self.contentView addSubview:_infoLabel];
        [_infoLabel mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(self.titleLabel.mas_bottom).mas_offset(12);
            make.left.right.equalTo(self.titleLabel);
//            make.bottom.equalTo(self.contentView).offset(-5);
        }];
        
        
    }
    return self;
}

- (void)setModel:(TTCertificateItemModel *)model
{
    _model = model;
    self.titleLabel.text = model.title;
    self.infoLabel.text = model.infoStr;
    
    [self setSelected:model.isSelected];
    
}

- (void)setSelected:(BOOL)selected
{
    [super setSelected:selected];
    
    if (selected) {
        self.layer.borderColor = UIColorHex(#8B57E6).CGColor;
        self.backgroundColor = UIColorHex(#F5F0FF);
        self.titleLabel.textColor = UIColorHex(#8B57E6);
        self.infoLabel.textColor = UIColorHex(#8B57E6);
    } else {
        self.backgroundColor = UIColorHex(#F5F5F5);
        self.layer.borderColor = self.backgroundColor.CGColor;
        self.titleLabel.textColor = UIColorHex(333333);
        self.infoLabel.textColor = UIColorHex(333333);
    }
    
}



@end
